home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmiSoft / Util / conv / IFF2rexx.lha / IFF2rexx.rexx < prev   
OS/2 REXX Batch file  |  2004-01-19  |  1KB  |  29 lines

  1. /* $VER: IFF2rexx 1.0 $
  2.  * Convert IFF data to rexx source
  3.  * © by Stefan Haubenthal 2004 */
  4.  
  5. if ~open(iff,arg(1)) then exit 0*writeln(stdout,"Usage: IFF2rexx ifffile")
  6. if readch(iff,4)~=FORM then exit 10+0*writeln(stdout,"Error: This is not an IFF file")
  7. say '/* Generated by 'word(sourceline(1),3)' V'word(sourceline(1),4)' */'
  8. say 'call open(iff,"'substr(arg(1),max(lastpos(":",arg(1)),lastpos("/",arg(1)))+1)'",W)'
  9. say 'call writech(iff,"FORM")'
  10. len=c2d(readch(iff,4))
  11. say 'call writech(iff,d2c('len',4))'
  12. type=readch(iff,4)
  13. say 'call writech(iff,"'type'")'
  14. do forever
  15.     chunk=readch(iff,4)
  16.     if eof(iff) then leave
  17.     say 'call writech(iff,"'chunk'")'
  18.     len=c2d(readch(iff,4))
  19.     say 'call writech(iff,d2c('len',4))'
  20.     do len%8 while ~eof(iff)
  21.         data=readch(iff,8)
  22.         say 'call writech(iff,"'c2x(data)'"x)    /* 'translate(data,,xrange(,'1f'x))' */'
  23.     end
  24.     data=readch(iff,len//8)
  25.     say 'call writech(iff,"'c2x(data)'"x)    /* 'translate(data,,xrange(,'1f'x))' */'
  26.     data=readch(iff,len//2)
  27.     if len//2 then say 'call writech(iff,"00"x)    /* pad */'
  28. end
  29.